package org.sgr.money.manager.frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class AddToolbarToTabFolder {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display, SWT.SHELL_TRIM);
		shell.setText("TabFolder");
		shell.setLayout(new FillLayout());

		TabFolder folder = new TabFolder(shell, SWT.NONE);
		TabItem item1 = new TabItem(folder, SWT.NONE);
		item1.setText("ToolBar");

		// create the composite for ToolBar
		final Composite toolComp = new Composite(folder, SWT.NONE);
		GridData suGridData = new GridData(GridData.FILL_BOTH);
		toolComp.setLayoutData(suGridData);
		toolComp.setLayout(new GridLayout(1, true));

		// add toolbar on the toolComp
		ToolBar toolBar = new ToolBar(toolComp, SWT.NONE);
		ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
		saveItem.setText("Save");

		// [color=#FF0000] //set the "toolComp" is being controlled,this is
		// necessary!!
		item1.setControl(toolComp);// [/color]

		TabItem item2 = new TabItem(folder, SWT.NONE);
		item2.setText("radio");
		Group group2 = new Group(folder, SWT.NONE);
		group2.setText("Radio Group");
		group2.setLayout(new GridLayout());
		Button radio1 = new Button(group2, SWT.RADIO);
		radio1.setText("radio1");
		Button radio2 = new Button(group2, SWT.RADIO);
		radio2.setText("radio2");
		item2.setControl(group2);

		shell.setVisible(true);
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
